$(function () {
    init_shopdetail();
    back();
    update_shop();
});

function init_shopdetail() {
    $.ajax({
        url: '/get-shop-detail',
        type: 'get',
        dataType: 'JSON',
        success: function (data) {
            if (data.status) {
                var result = data.result;
                $('#name').text(result['name']);
                $('#image').attr('src', result['image']);
                $('#price').text(result['price']);
                $('#num').text(result['num']);
            } else {
                alert('数据获取失败');
            }
        }
    });
}

function back() {
    $('#back-button').click(() => {
        $.ajax({
            url: '/shop-destroy-session',
            type: 'get',
            data: 'JSON',
            success: function (data) {
                window.location.href = '/page/shoper-main.html';
            }
        });
    });
}

function update_shop() {
    $('#update-shop').click(() => {
        window.location.href = '/page/shoper-shopupdate.html';
    });
}